package com.jb.util;

public class StringUtil {

    public static String itemNameToLabel(String itemName) {
        if(itemName==null ||itemName.length()==0)
            return itemName;
        
        try {
            String cap = itemName.toUpperCase();
            if(cap.equals(itemName))
                return itemName;
            
            StringBuffer sb = new StringBuffer(itemName);

            for (int i = sb.length() - 1; i > -1; i--) {
                if (sb.charAt(i) < 'a') {
                    sb.insert(i, " ");
                }
            }
            sb.replace(0, 1, itemName.substring(0, 1).toUpperCase());
            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return itemName;
    }
}
